#include "common.h"

FILE * logfile = NULL;

const char warships[34] = {' ','~','D','d','S','s',' ',' ','C','c',
                           ' ',' ',' ',' ',' ',' ','B','b',' ',' ',
                           ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
                           ' ',' ','A','a',};

int Noprint(FILE * fp, char* fmt, ...)
{
    return 0;
}

int Noprintf(char* fmt, ...)
{
    return 0;
}

void printBF(Battlefield * BF)
{
    for(int i=0;i<M;i++)
    {
        for(int j=0;j<M;j++)
        {
            char c = warships[BF->area[i][j]];
            DBGP(logfile, "%c", c);
        }
        DBGP(logfile, "\n");
    }
}

void printALL(Battlefield * ABF, Battlefield * BBF)
{
    for(int i=0;i<M;i++)
    {
        for(int j=0;j<M;j++)
        {
            char c = warships[ABF->area[i][j]];
            DBGP(logfile, "%c", c);
        }
        DBGP(logfile, "    #    ");
        for(int j=0;j<M;j++)
        {
            char c = warships[BBF->area[i][j]];
            DBGP(logfile, "%c", c);
        }
        DBGP(logfile, "\n");
    }
}

int isOver(Battlefield * BF)
{
    for(int i=0;i<M;i++)
    {
        for(int j=0;j<M;j++)
        {
            if((BF->area[i][j] & 0x1) == 0) // 末位为0代表没有被击中
                return 0;
        }
    }
    return 1;
}
